package com.hhs.storage.controller;


import com.hhs.storage.bean.BusinessDispatchOrder;
import com.hhs.storage.bean.BusinessOrder;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.service.BusinessDispatchOrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hhs
 * @since 2023-02-07
 */
@RestController
@RequestMapping("/businessDispatchOrder")
public class BusinessDispatchOrderController {
    @Resource
    private BusinessDispatchOrderService businessDispatchOrderService;
    @RequestMapping(value = "table")
    public Map<String, Object> getAll(BusinessDispatchOrder dispatchOrder, InputParam inputParam) {
        return businessDispatchOrderService.getAll(dispatchOrder,inputParam);
    }

    @PostMapping(value = "add")
    public Map<String, Object> add(@RequestParam String orderId,@RequestParam String carDataJson){
        return businessDispatchOrderService.add(orderId,carDataJson);
    }

    /**
     * 取消订单
     * @param id
     * @return
     */
    @PostMapping(value = "dele")
    public Map<String, Object> dele(@RequestParam String id,@RequestParam String reason){
        return businessDispatchOrderService.dele(id,reason);
    }

    /**
     * 修改状态
     * @param id
     * @param state
     * @return
     */
    @PostMapping(value = "changeState")
    public Map<String, Object> changeState(@RequestParam String id, @RequestParam Integer state){
        return businessDispatchOrderService.changeState(id,state);
    }

    /**
     *更新备注
     * @param id
     * @param remark
     * @return
     */
    @PostMapping(value = "updateRemark")
    public Map<String, Object> updateRemark(@RequestParam String id, @RequestParam String remark){
        return businessDispatchOrderService.updateRemark(id,remark);
    }
    @PostMapping(value = "changeCar")
    public Map<String, Object> changeCar(@RequestParam String id, @RequestParam String carId,@RequestParam String reason){
        return businessDispatchOrderService.changeCar(id,carId,reason);
    }
    @PostMapping(value = "detail")
    public Map<String, Object> detail(@RequestParam String id){
        return businessDispatchOrderService.detail(id);
    }

    //根据order的id，获取该单据下已分配的车辆数据
    @PostMapping(value = "getByOrderId")
    public Map<String, Object> getByOrderId(InputParam inputParam){
        return businessDispatchOrderService.getByOrderId(inputParam);
    }

    //填写磅单
    @PostMapping(value = "satchelEdit")
    public Map<String, Object> satchelEdit(String deleIdStr, MultipartFile[] voucherFilesList,BusinessDispatchOrder dispatchOrder, InputParam inputParam){
        return businessDispatchOrderService.satchelEdit(deleIdStr,voucherFilesList,dispatchOrder,inputParam);
    }
}

